<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/commons/include/html_doctype.html"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="/commons/page/codegen.jsp"%>
<script type="text/javascript"
	src="${ctx}/js/gpoint/rdp/department/department.js">
	
</script>

<style type="text/css">
#leftTree {
	float: left;
	width: 18%;
	margin-left: 1%;
	height: 98%;
	overflow: auto;
	border: 1px solid #e5e5e5;
	background-color: #f5f5f5;
}

#listChannel {
	width: 78%;
	margin-right: 1%;
	float: right;
	height: 100%;
}
</style>
<title>部门管理列表</title>
</head>
<body>

	<div id="leftTree" class="">
		<ul id="channelTree" class="ztree">
		</ul>
	</div>

	<iframe id="listChannel" Name="listChannel" frameborder=0
		src="${ctx}/rdp/popup/treeDetail.htm?orgcode="> 
	</iframe>




	<script type="text/javascript">
	    var zTreeObj;

		var setting = {

			view : {
				selectedMulti : true, //设置是否能够同时选中多个节点

				showIcon : true, //设置是否显示节点图标

				showLine : true, //设置是否显示节点与节点之间的连线

				showTitle : true, //设置是否显示节点的title提示信息
			},

			data : {
				simpleData : {
					enable : true, //设置是否启用简单数据格式（zTree支持标准数据格式跟简单数据格式，上面例子中是标准数据格式）		
					idKey : "orgcode", //设置启用简单数据格式时id对应的属性名称								  
					pIdKey : "parentcode", //设置启用简单数据格式时parentId对应的属性名称,ztree根据id及pid层级关系构建树结构
					rootPId : "0",//根节点ID
				},
				key : {
					name : "orgname"
				}

			},

			check : {
				//设置是否显示checkbox复选框
				enable : true			
			},
			callback: {
				  onAsyncSuccess : ztreeOnAsyncSuccess,

				  onClick: onClick,  //定义节点单击事件回调函数
			
				  onDblClick: onDblClick, //定义节点双击事件回调函数

				  onCheck: onCheck  //定义节点复选框选中或取消选中事件的回调函数

			},
			async: {

				  enable: true,   //设置启用异步加载

				  type: "get",   //异步加载类型:post和get

				  contentType: "application/json", //定义ajax提交参数的参数类型，一般为json格式

				  url: "${ctx}/rdp/card/department/department/getTreeData.htm"  //定义数据请求路径

				 // autoParam: ["id=id", "name=name"] //定义提交时参数的名称，=号前面标识节点属性，后面标识提交时json数据中参数的名称

			 }

		};
		
		$(document).ready(function() {
			zTreeObj = $.fn.zTree.init($("#channelTree"), setting);
			
		});

		function ztreeOnAsyncSuccess(){
			//zTreeObj.expandAll(true);
		}
		
		
		function getDeptTreeData() {
			var treeData = [];
			var url = "${ctx}/rdp/department/department/getTreeData";
			$.ajax({
				url : url,
				type : "GET",
				contentType : "application/json",
				dataType : "json",
				async : false,
				success : function(data) {
					treeData = data;
				}
			});
			return treeData;
		}

		function onClick() {

		}
		
		function onDblClick() {

		}
		
		function onCheck() {
			  var treeObj = $.fn.zTree.getZTreeObj("channelTree"); //获取树对象
			  var nodes = treeObj.getCheckedNodes(true); 
			  var designIds = [];
			  $.each(nodes, function (i, item) {
				  //if (!item.isParent){
					  designIds.push(item.orgcode);   //選中的叶子节点
				  //}			     
			  });			  
			  console.log(designIds);
			  var idStr = designIds.toString(); 
			  var newSrc = "${ctx}/rdp/popup/treeDetail.htm?orgcode="+idStr;			  
			  $("#listChannel").attr("src",newSrc);
		}
		
		
		
		
		
		
		
	</script>

</body>

</html>